/**
 * @program: LeetCode
 * @description: LeetCode : 941. 有效的山脉数组
 * @author: WXY
 * @create: 2023-02-06 20:08
 * @Version 1.0
 **/
public class Num941_validMountainArray {
    public static boolean validMountainArray(int[] arr) {
        if (arr.length < 3) {
            return false;
        }
        int left = 0;
        int right = arr.length - 1;
        while (left + 1 < arr.length && arr[left] < arr[left + 1]) {
            left++;
        }
        while (right > 0 && arr[right] < arr[right - 1]) {
            right--;
        }
        if (left == right && right != arr.length - 1 && left != 0) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        int[] arr = {0,2,3};
        boolean mountainArray = validMountainArray(arr);
        System.out.println(mountainArray);

    }
}
